using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TEST
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            Random ran = new Random();
            int RandKey = ran.Next(1000, 9999);
            string B = RandKey.ToString();

            label4.Text = B;


               
        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

  

        private void button1_Click(object sender, EventArgs e)
        {

           
            ////////判断用户名、密码、验证码是否输入的开始///////
           
                if (textBox1.Text == "")
              label5.Visible = true;
          
                if (textBox2.Text == "")
                label6.Visible = true;
           
                if (textBox3.Text == "")
                label7.Visible = true;

           if (textBox3.Text == "")
            {
                label7.Visible = true;
                label7.Text = "请输入验证码";
            }
            if (textBox3.Text != label4.Text)
                if (textBox3.Text != "")
                {
                    label7.Visible = true;
                    label7.Text = "验证码错误";
                }
           
            ////////判断用户名、密码、验证码是否输入的结束///////
            ////////判断用户名是否输入正确开始////////
            if (textBox3.Text == label4.Text)
                if (textBox1.Text == "1234") ///如果正确/////
                if (textBox2.Text == "1234") 
                  
                        MessageBox.Show("登陆成功！");
            if (textBox3.Text == label4.Text)
                if (textBox1.Text != "") ///如果不正确/////
                if (textBox1.Text != "1234")
                        if (textBox2.Text != "")
                        {                                      ///执行多段代码用{}框住
                label5.Text = "账号不存在";
                    label5.Visible = true;
            }
            if (textBox3.Text == label4.Text)
               if (textBox1.Text == "1234") ///如果账号正确但密码不正确/////
                   if (textBox2.Text != "1234")
                {
                    label6.Text = "密码错误";
                    label6.Visible = true;
                }
                   




        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Random ran = new Random();
            int RandKey = ran.Next(1000, 9999);
            string B = RandKey.ToString();

            label4.Text = B;
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Random ran = new Random();
            int RandKey = ran.Next(1000, 9999);
            string B = RandKey.ToString();

            label4.Text = B;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            label5.Visible = false;
            label5.Text = "请输入账号";
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            label6.Visible = false;
            label6.Text = "请输入密码";
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            label7.Visible = false;
            label7.Text = "请输入验证码";
        }
    }
}
